﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using PRDP.Tools;
using ASP;

public partial class advanceSearch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ddlSearchType.Attributes.Add("onchange", "f5AdvanceSearchPanel(options[selectedIndex].value)");
        createTypeRowsStart();
        Page.ClientScript.RegisterStartupScript(this.GetType(), "initialGetAdvanceSearchForm", "initialAdvanceSearchForm();", true);
    }

    public void createTypeRowsStart()
    {
        List<Hashtable> rows = MyDBHandler.getAllList("select CnName,ID from Type where PID=-1");
        foreach (Hashtable myRow in rows)
        {
            ListItem item = new ListItem(myRow["CnName"].ToString(), myRow["ID"].ToString());
            ddlSearchType.Items.Add(item);
            createTypeRows(myRow["ID"].ToString(), "--");
        }
    }
    public void createTypeRows(string id, string step)
    {
        List<Hashtable> rows = MyDBHandler.getAllList("select ID,CnName from Type where PID=" + id);
        foreach (Hashtable row in rows)
        {
            ListItem item = new ListItem(step + row["CnName"].ToString(), row["ID"].ToString());
            ddlSearchType.Items.Add(item);
            createTypeRows(row["ID"].ToString(), step + "--");
        }
    }
}
